#encoding: utf-8
module BlsHelper
  def bl_status(value)
    BlStatusEnum.get_enum_by_value(value).label
  end

  #def container_status(value)
  #  ContainerStatusEnum.get_enum_by_value(value).label
  #end
  # 虚拟属性
  # 提单中的集装箱概况
  # return::summary_str 集装箱概况字符串，如[20GP×2,40GP×2]
  def ctn_summary (bl)
    summary = {}
    bl.bl_containers.each do |ctn|
      if summary[ctn.ctn_type]
        summary[ctn.ctn_type] += 1
      else
        summary[ctn.ctn_type] = 1
      end
    end
    summary_str = []
    summary.each do |ctn_type, value|
      summary_str << "#{ctn_type}×#{value}"
    end
    "[" + summary_str.join(',')+"]"
  end

end
